<template>
  <view class="test">
    <input type="text" v-model="formData.mobile" placeholder="手机号" />
    <input type="text" v-model="formData.password" placeholder="密码" />
    <button @tap="getTestData">测试请求-账号密码登录</button>
    <button @tap="getMobileCode">获取验证码</button>
  </view>

  <view>计数: {{ store.count }}</view>
  <view>双倍: {{ store.double }}</view>
  <button @click="store.increment()">加1</button>
  <button @click="store.decrement()">减1</button>
</template>

<script lang="ts" setup>
export interface LoginData {
  /**
   * 用户名
   */
  account?: string
  /**
   * 头像
   */
  avatar?: string
  /**
   * 用户id
   */
  id?: string
  /**
   * 脱敏手机号，带星号的手机号
   */
  mobile?: string
  /**
   * refreshToken
   */
  refreshToken: string
  /**
   * token
   */
  token: string
}
import { getCodeAPI, postLoginPasswordAPI } from '@/apis/common'
import { useCounterStore } from '@/stores/counter'
import { request, service } from '@/utils/request'
import { ref } from 'vue'

const store = useCounterStore()
const formData = ref({
  mobile: '13230000001',
  password: 'abc12345',
})
const getTestData = async () => {
  // request.get()
  // request.post()
  // const res = await service.request({
  //   url: '/login/password',
  //   method: 'POST',
  //   data: formData.value,
  // })
  // const res = await request<LoginData>('/login/password','POST', formData.value,{
  //   custom:{
  //     loading:true
  //   }
  // })
  // console.log(res)
  const res = await postLoginPasswordAPI(formData.value)
  console.log(res)
}

const getMobileCode = async () => {
  const res = await getCodeAPI({
    mobile: formData.value.mobile,
    type: 'login',
  })
  console.log(res)
}
</script>

<style lang="scss"></style>
